package com.bnlr.lrparking.appui.stall;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bnlr.lrparking.R;
import com.bnlr.lrparking.base.BaseActivity;
import com.bnlr.lrparking.model.StallListM;

/**
 * 我的车位详情
 *
 * @author Administrator
 * @date 2017/6/7
 */
public class MyStallDetailsActivity extends BaseActivity {

    private TextView tvNavTitle;
    private StallListM.DataBean detailBean;
    private TextView stalltedails_check, stalldetails_number, stalldetails_address,
            stalldetails_phone, stalldetails_type, stalldetails_price, stalldetails_describe;
    private ImageView image_stalltedails, car_place_iv;
    /**
     * 审核成功，审核失败
     */
    private LinearLayout line_audit_succeed, line_audit_defeated;
    /**
     * 审核中
     */
    private RelativeLayout car_audit;
    /**
     * 审核失败
     */
    private RelativeLayout car_defeated;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_stall_details);
        initView();
    }

    private void initView() {
        Intent intent = getIntent();
        detailBean = (StallListM.DataBean) intent.getSerializableExtra("place_detail");
        tvNavTitle = (TextView) findViewById(R.id.tv_nav_title);
        tvNavTitle.setText("车位详情");
        line_audit_succeed = (LinearLayout) findViewById(R.id.line_audit_succeed);
        line_audit_defeated = (LinearLayout) findViewById(R.id.line_audit_defeated);
        car_audit = (RelativeLayout) findViewById(R.id.car_audit);
        car_defeated = (RelativeLayout) findViewById(R.id.car_defeated);
        stalltedails_check = (TextView) findViewById(R.id.stalltedails_check);
        image_stalltedails = (ImageView) findViewById(R.id.image_stalltedails);
        car_place_iv = (ImageView) findViewById(R.id.car_place_iv);
        stalldetails_number = (TextView) findViewById(R.id.stalldetails_number);
        stalldetails_address = (TextView) findViewById(R.id.stalldetails_address);
        stalldetails_phone = (TextView) findViewById(R.id.stalldetails_phone);
        stalldetails_type = (TextView) findViewById(R.id.stalldetails_type);
        stalldetails_price = (TextView) findViewById(R.id.stalldetails_price);
        stalldetails_describe = (TextView) findViewById(R.id.stalldetails_describe);
        if (detailBean.getStatus().equals("0")) {
            line_audit_succeed.setVisibility(View.VISIBLE);
            line_audit_defeated.setVisibility(View.GONE);
            stalltedails_check.setText("已审核");
            stalltedails_check.setTextColor(getResources().getColor(R.color.main_color));
            image_stalltedails.setImageResource(R.mipmap.icon_me_check3);
        } else if (detailBean.getStatus().equals("2")) {
            line_audit_succeed.setVisibility(View.GONE);
            line_audit_defeated.setVisibility(View.VISIBLE);
            car_audit.setVisibility(View.VISIBLE);
            car_defeated.setVisibility(View.GONE);
            stalltedails_check.setText("审核中");
            stalltedails_check.setTextColor(getResources().getColor(R.color.gray03_color));
            image_stalltedails.setImageResource(R.mipmap.icon_me_check1);
        } else if (detailBean.getStatus().equals("3")) {
            line_audit_succeed.setVisibility(View.GONE);
            line_audit_defeated.setVisibility(View.VISIBLE);
            car_audit.setVisibility(View.GONE);
            car_defeated.setVisibility(View.VISIBLE);
            stalltedails_check.setText("审核失败");
            stalltedails_check.setTextColor(getResources().getColor(R.color.order_type));
            image_stalltedails.setImageResource(R.mipmap.icon_me_check2);
        }
        stalldetails_number.setText("车位编号：" + detailBean.getNumber());
        stalldetails_address.setText("车场名称：" + detailBean.getAddress());
        stalldetails_phone.setText("业主电话：" + detailBean.getPhone());
        stalldetails_type.setText("车位类型：" + detailBean.getType());
        stalldetails_price.setText("出售价格：" + detailBean.getSellingprice() + "  RMB");
        if (detailBean.getDescription() != null) {
            stalldetails_describe.setText(detailBean.getDescription());
        } else {
            stalldetails_describe.setText("无");
        }
        Glide.with(this).load(detailBean.getParkphoto()).error(R.mipmap.img_stall_error).into(car_place_iv);
    }
}
